<!--
学习计划查看
 add by yyp 2019-05-14
-->
<template lang="pug">
  kalix-dialog.user-add(title='查看' bizKey="StudyPlan" ref="kalixBizDialog" v-bind:submitBefore="submitBefore" v-bind:formModel.sync="formModel" isView)
    div.el-form(slot="dialogFormSlot")
      template(slot="tableColumnSlot")
      el-form-item(label="学习计划标题" prop="planTitle" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.planTitle" readonly)
      el-form-item(label="学习计划创建日期" prop="planDate" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.planDate" readonly)
          template(slot-scope="scope")
            span {{dataFormat(scope.row.planDate)}}
      el-form-item(label="学习计划详情" prop="planContent" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.planContent" readonly)
      el-form-item(label="学习计划开始时间" prop="planStartTime" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.planStartTime" readonly)
          template(slot-scope="scope")
            span {{dataFormat(scope.row.planStartTime)}}
      el-form-item(label="学习计划结束时间" prop="planEndTime" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.planEndTime" readonly)
          template(slot-scope="scope")
            span {{dataFormat(scope.row.planEndTime)}}
      el-form-item(label="学生ID" prop="studentId" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.studentId" readonly)



</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import {baseURL} from '../../../../../config/global.toml'
  import KalixSelect from '../../../../../components/corelib/components/common/baseSelect'
  import KalixImgUpload from '../../../../../components/corelib/components/common/imgUpload'
  export default {
    name: 'studyplanView',
    components: {
      KalixSelect,
      KalixClansmanUpload,
      KalixImgUpload
    },
    data() {
      return {
        action: baseURL + '/camel/rest/upload',
        formModel: Object.assign({}, FormModel),
        labelWidth: '120px'
      }
    },
    methods: {
      dataFormat(val) {
        let d = new Date(val)
        return this.$M_FormatDate(d, 'yyyy-MM-dd')
      },
      ImgDel(imgUrl) {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(() => {
          let arrImg = this.formModel.imgUrl.split(',')
          console.log('arrImg++++++++++++++', arrImg)
          let idx = arrImg.indexOf(imgUrl)
          arrImg.splice(idx, 1)
          this.formModel.imgUrl = arrImg.join(',')
          console.log('this.formModel.imgUrl++++++++++++++', this.formModel.imgUrl)
          // this.filePathArr = arrImg
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
      init(dialogOption) {
        console.log('---------dialogOption------------', dialogOption)
      },
      getFilePath(filePath, fileName) {
        console.log('--getFilePath---', filePath)
        console.log('--fileName---', fileName)

        this.formModel.newUrl = filePath
        this.formModel.imgName = fileName
      },
      submitBefore(baseDialog, callBack) {
        console.log('this.filePathArr+++++++++++++++++', this.filePathArr)
        let filePath = ''
        if (this.filePathArr.length > 0) {
          this.filePathArr.forEach(e => {
            filePath += e + ','
          })
          filePath = filePath.substr(0, filePath.length - 1)
        }
        console.log('filePath+++++++++++++++++', filePath)
        // let photoStr = this.formModel.photo !== '' ? this.formModel.photo : ''
        if (filePath.length > 0) {
          if (this.formModel.imgurl === '') {
            baseDialog.formModel.imgurl = filePath
          } else {
            baseDialog.formModel.imgurl = this.formModel.imgurl + ',' + filePath
          }
        }
        this.formModel.modifyStaff = this.$KalixCatch.get('user_name')
        callBack()
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .el-form
    width 50%
    margin auto
    .radio
      margin-left 150px
      margin-bottom 20px
      .el-radio
        color: #3465cb
        font-weight: bold
        font-size: 14px
  .img-margin
    margin-left 150px
</style>
